Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

203
Visualizações
Why i get error "unreachable code" when i try to put an if in my function?

When i insert "if (descriptions >= 0.4){zien()} then it gets red underlined with error "unreachable code". Why is that??

function loadLabeledImages() {
  const labels = ['Simon', 'Thomas'];
  return Promise.all(
    labels.map(async (label) => {
      const img = await faceapi.fetchImage(`./images/${label}.jpg`);
      const detections = await faceapi
      .detectSingleFace(img)
      .withFaceLandmarks()
      .withFaceDescriptor();
      const descriptions = [detections.descriptor];
      return new faceapi.LabeledFaceDescriptors(label, descriptions);

      if (descriptions >= 0.4){
        zien()
      }
    }),

  );

}

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The fact is it an if is irrelevant. It is code that appears after a return statement.

When running the function, the JS engine will always return from the function before reaching the if. Since it can never reach the if, the if is unreachable.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda